<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace api\home\controller;

use think\Db;
use think\Validate;
use cmf\controller\RestBaseController;
use app\admin\model\LinkModel;

class IndexController extends RestBaseController
{
    // api 首页
    public function index()
    {
        $this->success("恭喜您,API访问成功!", [
            'version' => '1.1.0',
            'doc'     => 'http://www.thinkcmf.com/cmf5api.html'
        ]);
    }

    // api 首页友情连接
    public function link()
    {
        $linkModel = new LinkModel();
        $links     = $linkModel->select()->toArray();

        $this->success("获取友情连接成功!", $links);
    }


    /**
     * 获取新建项目列表
     */
    public function project_type()
    {
        $result = Db::name("project_type")->select()->toArray();

        foreach ($result as &$v) {
            $v['l_id'] = explode(',', $v['l_id']);
        }
        unset($v);

        $this->success('获取成功!', $result);

    }



    /**
     * 获取附件类型ID
     */
    public function getAnnexType()
    {
        $result = Db::name("pro_annex_type")->select();

        $this->success('获取成功!', $result);
    }



    /**
     * 获取六张表的变量
     */
    public function getVariable()
    {
        $data = $this->request->param();

        if (empty($data['val'])) $this->error("参数错误!");

        $val = $data['val'];

        $varlist = Db::name($val)->find();

        $this->success('获取变量成功!', $varlist);
    }


}
